package com.clstu.generic;

import java.util.ArrayList;

public class Generic03 {
    public static void main(String[] args) {
        Person<String> person = new Person<>("hello");
        Person<Integer> person1 = new Person<>(20);
        System.out.println(person.f());
        System.out.println(person1.f());
        person.t();
        person1.t();
        Person person2 = new Person("helloWorld");//不填尖括号里面的类型则根据参数自行判断
        System.out.println(person2.f());
        person2.t();

    }
}
class Person<E>{//泛型就是E具体是代表什么类型不确定，创建对象的时候自行确定.
    private E s;
    public Person(E s){
        this.s=s;
    }
    public E f(){
        return s;
    }
    public void t(){
        System.out.println(s.getClass());
    }
}